<include file="header" />
<head>
	<link rel="stylesheet" href="/assets/zyyirs/css/countdown.css?version=1">
</head>
<body>
<div class="wraper">

    <div class="top">
        <p>
            <a onclick ="javascript:history.go(-1);" class="iconfont icon-zuo pull-left"></a>
            <a href="javascript:void(0);" class="order-all pull-left">确认订单</a>
        </p>
	    <input type="hidden" id="send_price" value="{BEESCRM:$sendPrice}">
	    <input type="hidden" id="close_time" value="{BEESCRM:$closeTime}">
	    <input type="hidden" id="orderId" value="{BEESCRM:$order_id}">
	    <input type="hidden" id="irsId" value="{BEESCRM:$irs_id}">
    </div>
	<div class="tips">
		温馨提示：付款后不能退单,请在<strong id="minute_show">0分</strong>
		<strong id="second_show">0秒</strong>内完成付款</br>
	</div>

    <div class="order-info topnone">
        <div class="lists">就餐地点:{BEESCRM:$restaurant_name}</div>
    </div>
    <div class="order-info">
        <div class="lists tb-mode">
            <div class="tb-cell list-left">就餐时间</div>
            <div class="tb-cell list-right">
                <select id="send_time">
		                <option>{BEESCRM:$eatTime}</option>
                </select>
            </div>
        </div>
    </div>
    <div class="order-info">
        <div class="lists tb-mode">
            <div class="tb-cell list-left">支付方式</div>
            <div class="tb-cell list-right">
	            <a href="javascript:void(0);" class="order-btn weipay" data-type="1">微信支付</a></div>
        </div>
    </div>


    <div class="order-lists lists">
        <div class="lists tb-mode">
	        <div class="tb-cell list-left">餐品列表</div>
        </div>
        <volist name="goodList" id="vo">
	    <div class="lists tb-mode foods">
            <a href="javascript:void(0);" class="tb-cell list-left">
                <div class="img-box"><img src="{BEESCRM:$vo['goods_logo']}"></div>
            </a>
            <a href="javascript:void(0);" class="tb-cell list-center">
                <p>{BEESCRM:$vo['goods_name']}</p>
                <p class="prize">{BEESCRM:$vo['goods_price']}元</p>
            </a>
            <div class="tb-cell list-right">
                <div class="tb-mode amount" style="text-align: center;border:0;">
	                {BEESCRM:$vo['goods_num']}<span class="wd-good" style="display: none;">x1</span>
                </div>
            </div>
        </div>
        </volist>
        <div class="lists tb-mode">
            <div class="tb-cell list-right" style="line-height: 1.5;">
				<p id="sendPrice">餐盒费：0元</p>
				<p>积分优惠：0元</p>
				<p>
					总价：<span class="num" id="orderPrice">{BEESCRM:$data.moneySum}元</span>
					<input type="hidden" value="{BEESCRM:$data.moneySum}" id="orderAmount">
				</p>
			</div>
        </div>

        <div class="lists bottom-none">
            <input value="" placeholder="特殊需要请备注" id="memo"/>
        </div>
    </div>
	<input type="hidden" class="restaurant_id" value="{BEESCRM:$restaurant_id}">
	<input type="hidden" id="irs_id" value="{BEESCRM:$irs_id}">
	<input type="hidden" id="takeout" value="{BEESCRM:$takeout}">
	<input type="hidden" id="amount" value="{BEESCRM:$amount}">
	<input type="hidden" id="freight" value="{BEESCRM:$freight}">
    <div class="btn-box">
        <a href="javascript:void(0)" class="btn green-btn pay-btn" data-order_id="{BEESCRM:$order_id}">立即付款</a>
    </div>
</div>

<include file="commonJS" />
<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
<script src="/assets/zyyirs/js/order.js?version=1"></script>
<script src="/assets/zyyirs/js/countdown.js?version=1"></script>
<script>
    $('.classify').click(function(){
        $('.menu-lists').addClass('show-menu');
    })
    $('.close').click(function(){
        $('.menu-lists').removeClass('show-menu');
    })
</script>
<script>
	var closeTime = $("#close_time").val();
	var irsId = $("#irsId").val();
	var orderId = $("#orderId").val();

//	window.onload = function(){
//		var take = $('#takeout').val();
//		var amount = $('#amount').val();
//		var freight = $('#freight').val();
//		if(take == 1){
//			var checkbox = $("#checkboxFourInput").find('.iconfont');
//			$(checkbox).removeClass('icon-checkbox').addClass('icon-checked');
//			$("#sendPrice").html("餐盒费:"+freight+"元");
//			$("#orderPrice").html(amount+'元');
//		}
//	};

	//是否外带按钮
//	$("#checkboxFourInput").on('click',function(){
//		var sendPrice = $("#send_price").val();
//		var checkbox = $("#checkboxFourInput").find('.iconfont');
//		if($(checkbox).hasClass('icon-checkbox')) {
//			$(checkbox).removeClass('icon-checkbox').addClass('icon-checked');
//			upOrder(1,sendPrice);
//		}else{
//			$(checkbox).addClass('icon-checkbox').removeClass('icon-checked');
//			upOrder(0,0);
//		}
//	});

	//增减外带份数
	$(".change-num-btn").on('click',function(){
		var s = $(this).data('status');
		var num = $("#wd-num").val();
		var sendPrice = $("#send_price").val();
		if(s == 'sub'){//-
			var sub_num = parseInt(num) - 1;
			if(sub_num >= 1){
				upWdOrder(sub_num,orderId,sendPrice);

			}
		}else if(s == 'plus'){//+
			var plus_num = 1 + parseInt(num);
			upWdOrder(plus_num,orderId,sendPrice);
		}

	});

	//修改外带订单
	function upWdOrder(num,orderId,sendPrice){
		var info = {};
		info.orderId = orderId;
		info.num = num;
		info.sendPrice = sendPrice;
		$.ajax({
			'url': "/Zyyirs/irs/carryOrder?irs_id="+irsId,
			'data': info,
			'dataType':'json',
			'type': 'POST',
			'async': false,
			success: function(data) {
				if(data.status == 'S'){
					$("#wd-num").val(data.num);
				}else{
					fm.alert(data.message);
				}
			}
		});
	}


	//是否为外带订单
	function upOrder(besides,sendPrice){
		var orderId = $("#orderId").val();
		var info = {};
		info.orderId = orderId;
		info.besides = besides;
		info.sendPrice = sendPrice;
		$.ajax({
			'url': "/Zyyirs/irs/besidesOrder?irs_id="+irsId,
			'data': info,
			'dataType':'json',
			'type': 'POST',
			'async': false,
			success: function(data) {
				if (data.status == 'S') {
					var orderAmount = $("#orderAmount").val();
					if(besides == 1){
						var orderPrice = parseFloat(orderAmount) + parseFloat(data.sendPrice);
						$("#sendPrice").html("餐盒费:"+data.sendPrice+"元");
						$("#orderPrice").html(orderPrice.toFixed(2)+'元');
					}else{
						$("#sendPrice").html("餐盒费:0元");
						$("#orderPrice").html(orderAmount+'元');
					}
				}else{
					fm.alert(data.message);
				}
			}
		});
	}

	//选择口味
	$("#flavor_inp").change(function(){
		//修改订单口味
		var info = {};
		info.orderId = orderId;
		info.flavor = $("#flavor_inp option:selected").val();;
		$.ajax({
			'url': "/Zyyirs/irs/flavorOrder?irs_id="+irsId,
			'data': info,
			'dataType':'json',
			'type': 'POST',
			'async': false,
			success: function(data) {
				if (data.status == 'S') {}else{}
			}
		});
	})
</script>
</body>
</html>
